﻿function StopButton() {
    document.getElementById(arguments[0]).disabled = true;
    document.getElementById(arguments[0]).value = "获取手机验证码(" + arguments[1] + ")";
    if (--arguments[1] > 0) {
        window.setTimeout("StopButton('" + arguments[0] + "'," + arguments[1] + ")", 1000);
    }
    if (arguments[1] <= 0) {
        document.getElementById(arguments[0]).value = '获取手机验证码';
        document.getElementById(arguments[0]).disabled = false;
    }
}

function GetComment($ID, $Page) {
    $.ajax({
    url: "../SendVerifyCode.aspx?action=ajax_getcomment&id=" + $ID + "&page=" + $Page + "&time" + new Date().toString(),
        type: 'GET',
        success: function() {
            
        }
    });
}

function SendComment() {
    var $CommentParentID = arguments[0];
    var regMobileNO = /^(((13[0-9]{1})|18[0-9]{1}|(15[0-9]{1}))+\d{8})$/;
    var $phoneNO = $("input[id*=MobileNO]").val();
    
    if ($.trim($phoneNO) == '') {
        alert('请您填写手机号码！');
        $('input[id*=MobileNO]').focus(); 
        return false;
    }

    if ($phoneNO.length != 11) {
        alert('手机号码不能小于11位！');
        $("input[id*=MobileNO]").val("");
        $('input[id*=MobileNO]').focus();
        return false;
    }

    if (!regMobileNO.test($phoneNO)) {
        alert("请输入正确的手机号码！");
        $("input[id*=MobileNO]").val("");
        return false;
    }

    StopButton('CommentSubmit', 60);
    $.ajax({
        url: "../SendVerifyCode.aspx?action=ajax_sendcomment&commentparentid=" + $CommentParentID + "&number=" + $phoneNO + "&time=" + new Date().toString(),
        type: 'GET',
        success: function() {
            GetComment($CommentParentID, 1);
            //$("#MobileNO").val("");    
            alert("手机验证码已发送到您的手机上，请耐心等候！")
        }
    });
}